## Process this file with automake to produce Makefile.in

## File:    Makefile.am
## Author:  Sayan Chaliha
## Date:    November 15, 2011
## Breif:   Automake file; process with automake to produce Makefile.in
AUTOMAKE_OPTIONS = dist-bzip2 dist-zip check-news color-tests -Wall -Werror
ACLOCAL_AMFLAGS = -I m4 --install

AM_CXXFLAGS =
AM_LDFLAGS =
AM_LIBTOOLFLAGS =
TESTS_ENVIRONMENT =

nodist_pkginclude_HEADERS =
noinst_HEADERS =
BUILT_SOURCES =

lib_LTLIBRARIES =
check_LTLIBRARIES =
check_PROGRAMS =
TESTS =

CLEANFILES =
DISTCLEANFILES =

libcyan_headers =                     \
  include/lc_atomic_word.h            \
  include/lc_avl_tree.h               \
  include/lc_basic_string.h           \
  include/lc_char_traits.h            \
  include/lc_condition_variable.h     \
  include/lc_delegate.h               \
  include/lc_exception.h              \
  include/lc_file.h                   \
  include/lc_forward_decl.h           \
  include/lc_interval.h               \
  include/lc_iterator.h               \
  include/lc_linked_list.h            \
  include/lc_linked_list_impl.h       \
  include/lc_multi_reader_lock.h      \
  include/lc_mutex.h                  \
  include/lc_normal_iterator.h        \
  include/lc_numeric_limits.h         \
  include/lc_object.h                 \
  include/lc_pair.h                   \
  include/lc_scheduler.h              \
  include/lc_scope_guard.h            \
  include/lc_scoped_pointer.h         \
  include/lc_shutdown_policy.h        \
  include/lc_system.h                 \
  include/lc_system_exception.h       \
  include/lc_thread.h                 \
  include/lc_types.h                  \
  include/lc_thread_manager.h         \
  include/lc_thread_storage.h         \
  include/lc_thread_storage_pthread.h \
  include/libcyan.h                   \
  include/libcyan_internal.h

libcyan_generated_headers = \
  lc_config.h               \
  lc_inttypes.h             \
  lc_target.h

libcyan_unit_test_headers =          \
  test/include/lc_test_char_traits.h \
  test/include/lc_test_thread.h      \
  test/include/lc_test_avl_tree.h

libcyan_sources =             \
  src/lc_atomic_word.cpp      \
  src/lc_basic_string.cpp     \
  src/lc_exception.cpp        \
  src/lc_file.cpp             \
  src/lc_interval.cpp         \
  src/lc_system.cpp           \
  src/lc_system_exception.cpp \
  src/lc_thread_manager.cpp

libcyan_pthread_sources  =              \
  src/lc_thread_pthread.cpp             \
  src/lc_mutex_pthread.cpp              \
  src/lc_condition_variable_pthread.cpp \
  src/lc_multi_reader_lock_pthread.cpp

libcyan_winapi_sources =

libcyan_unit_test_sources =        \
  test/src/lc_test_char_traits.cpp \
  test/src/lc_test_thread.cpp      \
  test/src/lc_test_avl_tree.cpp    \
  test/src/lc_test_main.cpp

libcyan_unit_test_result_xml = \
  libcyan_unit_test_result.xml

libcyan_scripts =             \
  scripts/generic.sh          \
  scripts/update_templates.sh \
  autogen.sh

libcyan_templates =           \
  templates/configure.ac.in   \
  templates/libcyan.spec.in   \
  templates/CMakeLists.txt.in \
  templates/filelist          \
  templates/patterns

libcyan_xcode_projects =                             \
  xcode/libcyan.xcworkspace/contents.xcworkspacedata \
  xcode/libcyan.xcodeproj/project.pbxproj

libcyan_docs = \
  README       \
  AUTHORS      \
  ChangeLog    \
  COPYING      \
  INSTALL      \
  NEWS         \
  TODO

libgtest_headers =           \
  test/include/gtest/gtest.h \
  test/include/gtest/gtap.h

libgtest_sources = \
  test/src/gtest-all.cc

# Global flags
AM_CXXFLAGS += -I${srcdir}/include -Werror
AM_LDFLAGS += -no-undefined -prefer-pic -export-dynamic

# Multi-threading API support
if PTHREAD
  AM_CXXFLAGS += ${PTHREAD_CFLAGS}
  AM_LDFLAGS += ${PTHREAD_LIBS}
else !PTHREAD
  AM_CXXFLAGS += ${WINAPI_CFLAGS}
  AM_LDFLAGS += ${WINAPI_LIBS}
endif !PTHREAD

# Gcov code coverage testing support
if TEST_COVERAGE
  CLEANFILES += *.gcno *.gcda *.gcov
endif

# Rules for headers' management
nodist_pkginclude_HEADERS += libcyan.h.gch
BUILT_SOURCES += libcyan_internal.h.gch libcyan.h.gch
CLEANFILES += ${BUILT_SOURCES}
DISTCLEANFILES += ${libcyan_generated_headers}

libcyan_internal.h.gch: ${libcyan_generated_headers}
libcyan_internal.h.gch: ${srcdir}/include/libcyan_internal.h
	${CXXCOMPILE} -o $@ `test -f 'include/libcyan_internal.h' || echo \
    '${srcdir}/'`include/libcyan_internal.h

libcyan.h.gch: libcyan_internal.h.gch
libcyan.h.gch: ${srcdir}/include/*.h
	${CXXCOMPILE} -o $@ `test -f 'include/libcyan.h' || echo \
    '${srcdir}/'`include/libcyan.h

# Rules for building libcyan
lib_LTLIBRARIES += libcyan.la
noinst_HEADERS += ${libcyan_headers}
libcyan_la_CXXFLAGS = -D__CYAN_BUILD_DLL__ ${AM_CXXFLAGS}
libcyan_la_DEPENDENCIES = ${BUILT_SOURCES}
libcyan_la_SOURCES = ${libcyan_sources}
libcyan_la_LDFLAGS = ${AM_LDFLAGS} -release ${PACKAGE_VERSION}
libcyan_la_LDFLAGS += -version-info ${APIVERSION}:${REVISION}:${AGE}
EXTRA_libcyan_la_SOURCES = ${libcyan_pthread_sources} ${libcyan_winapi_sources}
if PTHREAD
  libcyan_la_SOURCES += ${libcyan_pthread_sources}
else !PTHREAD
  libcyan_la_SOURCES += ${libcyan_winapi_sources}
endif !PTHREAD

# Rules for building and running unit test suite
TESTS_ENVIRONMENT += GTEST_OUTPUT="xml:${libcyan_unit_test_result_xml}"
TESTS += unit-test
check_PROGRAMS += unit-test
noinst_HEADERS += ${libcyan_unit_test_headers}
unit_test_CXXFLAGS = ${AM_CXXFLAGS} -I${srcdir}/test/include
unit_test_LDADD = libcyan.la libgtest.la
unit_test_LDFLAGS = -no-fast-install -avoid-version
unit_test_SOURCES = ${libcyan_unit_test_sources}
DISTCLEANFILES += ${libcyan_unit_test_result_xml}

# Rules for building libgtest
check_LTLIBRARIES += libgtest.la
noinst_HEADERS += ${libgtest_headers}
libgtest_la_SOURCES = ${libgtest_sources}
libgtest_la_CXXFLAGS = ${AM_CXXFLAGS} -I${srcdir}/test/include -w
libgtest_la_LDFLAGS = ${AM_LDFLAGS} -avoid-version -no-fast-install

# Additional rules
-include ${top_srcdir}/aminclude_static.am
